package com.ego.product.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ego.product.po.SpuInfoDesc;
import com.ego.product.service.SpuInfoDescService;
import com.ego.common.util.Result;

/**
 * @program: ego
 * @description spu信息介绍控制器
 * @author KamTang
 * @date 2022-11-13 12:56:14
 */
@RestController
@RequestMapping("product/spuinfodesc")
public class SpuInfoDescController {

    @Autowired
    private SpuInfoDescService spuInfoDescService;

    /**
     * 信息
     */
    @GetMapping("/get/{spuId}")
    public Result get(@PathVariable("spuId") Long spuId){
		SpuInfoDesc spuInfoDesc = spuInfoDescService.getById(spuId);
        return Result.ok().put("spuInfoDesc", spuInfoDesc);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public Result save(@RequestBody SpuInfoDesc spuInfoDesc){
		spuInfoDescService.save(spuInfoDesc);
        return Result.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public Result update(@RequestBody SpuInfoDesc spuInfoDesc){
		spuInfoDescService.updateById(spuInfoDesc);
        return Result.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody Long[] spuIds){
		spuInfoDescService.removeByIds(Arrays.asList(spuIds));
        return Result.ok();
    }

}
